/*
 *  Copyright 2019-2020 Zheng Jie
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *  http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */
package me.zhengjie.modules.mnt.domain

import cn.hutool.core.bean.BeanUtil
import cn.hutool.core.bean.copier.CopyOptions
import io.swagger.v3.oas.annotations.media.Schema
import jakarta.persistence.Column
import jakarta.persistence.Entity
import jakarta.persistence.Id
import jakarta.persistence.Table
import org.hibernate.annotations.CreationTimestamp
import org.springframework.data.redis.core.RedisHash
import java.sql.Timestamp

/**
 * @author zhanghouying
 * @date 2019-08-24
 */
@Entity
@Table(name = "mnt_deploy_history")
@RedisHash("mnt_deploy_history")
data class DeployHistory (
    @Id
    @Column(name = "history_id")
    @Schema(description = "ID", hidden = true)
    var id: String? = null,

    @Schema(description =  "应用名称")
    var appName: String? = null,

    @Schema(description = "IP")
    var ip: String? = null,

    @CreationTimestamp
    @Schema(description = "部署时间")
    var deployDate: Timestamp? = null,

    @Schema(description = "部署者")
    var deployUser: String? = null,

    @Schema(description = "部署ID")
    var deployId: Long? = null

) {
    fun copy(source: DeployHistory?) {
        BeanUtil.copyProperties(source, this, CopyOptions.create().setIgnoreNullValue(true))
    }
}